﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContractsList.aspx.cs" Inherits="User_ContractsList" MasterPageFile="~/Site.master" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <br/>
    <asp:HyperLink ID="UserLink" runat="server" NavigateUrl="UserPanel.aspx">Панель пользователя</asp:HyperLink>
&nbsp; <span class="Apple-style-span" 
        style="color: rgb(105, 105, 105); font-family: 'Helvetica Neue', 'Lucida Grande', 'Segoe UI', Arial, Helvetica, Verdana, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">
    →&nbsp; </span> 
    <b><asp:Label ID="ContractsLabel" runat="server" Text="Контракты" ForeColor="black"></asp:Label></b><br/>
<br />

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSourceContracts" DataKeyNames="ContractId" 
        ondatabinding="GridView1_DataBinding" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:CommandField SelectText="Подробнее" ShowSelectButton="True" />
            <asp:BoundField DataField="ContractId" HeaderText="ContractId" 
                SortExpression="ContractId" InsertVisible="False" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="Кредит" HeaderText="Кредит" 
                SortExpression="Кредит" />
            <asp:BoundField DataField="Сумма" HeaderText="Сумма" 
                SortExpression="Сумма" />
            <asp:BoundField DataField="Валюта" HeaderText="Валюта" 
                SortExpression="Валюта" />
            <asp:BoundField DataField="Дата получения" HeaderText="Дата получения" 
                SortExpression="Дата получения" />
            <asp:CheckBoxField DataField="Досрочное погашение" 
                HeaderText="Досрочное погашение" SortExpression="Досрочное погашение" />
            <asp:BoundField DataField="Статус" HeaderText="Статус" 
                SortExpression="Статус" />
            <asp:BoundField HeaderText="Просроченно" />
        </Columns>
        <EmptyDataTemplate>
            Контрактов нет. Новый запрос можно оформить в разделе кредиты.
        </EmptyDataTemplate>
    </asp:GridView>


    <asp:SqlDataSource ID="SqlDataSourceContracts" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>" 
        
        
        SelectCommand="SELECT Contract.ContractId, Credit.Name AS Кредит, Contract.Amount AS Сумма, Currency.Name AS Валюта, Contract.CreationDate AS [Дата получения], Credit.AdvancedRepayment AS [Досрочное погашение], Status.Name AS Статус FROM Contract INNER JOIN Credit ON Contract.CreditId = Credit.CreditID INNER JOIN Currency ON Contract.CurrencyId = Currency.CurrencyID INNER JOIN Status ON Contract.StatusId = Status.StatusId INNER JOIN Company ON Contract.CompanyId = Company.CompanyId INNER JOIN UserProfile ON Company.CompanyId = UserProfile.CompanyId WHERE (UserProfile.ProfileId = @profileId)">
        <SelectParameters>
            <asp:Parameter Name="profileId" />
        </SelectParameters>
    </asp:SqlDataSource>

</asp:Content>
